<?php
function copyMysqlDatabase($databaseName,$newDatabaseName,$user,$pass)
{
    $command="mysqldump –u {$user} –p {$pass} {$databaseName} > {$databaseName}.dump";
    $success=shell_exec($command);
    if(is_null($success)) return false;
    $command="mysqldump –u {$user} –p {$pass} {$newDatabaseName} < {$databaseName}.dump";
    $success=shell_exec($command);
    if(is_null($success)) return false;
    return true;
}
function resetNaanalDatabase()
{
    $arrTableHierarchy=array
    (
        "adjustmentattribute"=>null,
        "feature"=>null,
        "organization"=>null,
        "permissiontype"=>null,
        "permissiontype"=>null,
        "tracking"=>null,
        "adjustmentattributemap"=>"adjustmentattribute",
        "client"=>"user",
        "clientrole"=>"client",
        "clientrolepermission"=>"client",
        "clientrolepermission"=>"clientrole",
        "clientrolepermission"=>"permission",
        "database"=>"client",
        "ipaddress"=>"client",
        "pagetemplate"=>"user",
        "permission"=>"permissiontype",
        "permission"=>"feature",
        "feature"=>"permission",
        "role"=>"user",
        "rolepermission"=>"permission",
        "rolepermission"=>"role",
        "user"=>"client",
        "userdatabase"=>"database",
        "userdatabase"=>"user",
        "userpermission"=>"user",
        "userpermission"=>"permission",
        "userrole"=>"role",
        "userrole"=>"user",
    );
    $arrTopLevelTable=array();
    $arrTableRelation=array();
    foreach($arrTableHierarchy as $table=>$parentTable)
    {
        if(is_null($parentTable))
        {
            $arrTopLevelTable[]=$table;
        }
        else
        {
            $arrTableRelation[$table]=$parentTable;
        }
    }
    foreach($arrTableRelation as $table=>$relatedTable)
    {
        foreach($arrTableRelation as $table=>$relatedTable)
        {

        }
    }
    $objPDO=ClsNaanalPDO::getNamedInstance();
}
?>